Skip to content

feat(webapp): route ClickHouse reads to an optional read replica#4081

Merged
ericallam merged 6 commits into
mainfrom
hotfix/runs-list-clickhouse-url
Jul 15, 2026
Merged

feat(webapp): route ClickHouse reads to an optional read replica#4081
ericallam merged 6 commits into
mainfrom
hotfix/runs-list-clickhouse-url

Conversation

@nicktrn

@nicktrn nicktrn commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds optional configuration to send ClickHouse read traffic to a separate instance (for example a read replica) while writes stay on the primary CLICKHOUSE_URL. This lets operators offload read load (runs list, traces, logs, queries) from the cluster that handles inserts. Fully backwards compatible: with nothing new set, every client resolves to CLICKHOUSE_URL exactly as before.

What it adds

  • CLICKHOUSE_READER_URL (optional): a single reader endpoint that the read-only clients fall back to. Read clients resolve <own URL> ?? CLICKHOUSE_READER_URL ?? CLICKHOUSE_URL. The task-events client (which both inserts events and reads traces, spans, and logs) is built as a reader/writer pair so queries use the reader while inserts stay on CLICKHOUSE_URL.
  • RUNS_LIST_CLICKHOUSE_URL (optional): a dedicated client for the runs list (dashboard list, runs list API, live reload, child-status counts), so the highest-traffic read path can target its own instance.

Safety

Only read-only clients fall back to the reader: logs, query, admin, runs list, the pending-version lookup, and the realtime run-id resolver. The query page is constrained to read-only (the TSQL parser rejects anything that is not a SELECT, and a readonly setting is applied). The task-events client routes inserts to the writer and queries to the reader per method, so a write can never reach the reader. Pure-write clients (event inserts, replication) always use CLICKHOUSE_URL.

Note: this PR targets a baseline branch rather than main so the diff stays scoped to the read-replica changes. It will be retargeted to main before merge.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6ff9f8a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds configurable ClickHouse reader and runs-list endpoints with fallback behavior in the environment schema. Extends the ClickHouse factory with a runsList client and optional separate events reader and writer routing. Updates run-list presenters and loaders to request the new client type, and documents the read-replica configuration.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description explains the change, but it misses required template sections like Closes #issue, checklist, testing, changelog, and screenshots. Add the missing template sections: Closes #issue, checklist items, Testing steps, Changelog, and Screenshots (or state none).
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: routing ClickHouse reads to an optional replica.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/runs-list-clickhouse-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@nicktrn nicktrn marked this pull request as draft June 30, 2026 18:15
nicktrn added 4 commits July 15, 2026 13:37
…reads

Runs list reads (dashboard list, runs list API, live reload, child-status
counts) went through the shared standard client (CLICKHOUSE_URL). Add a
dedicated runsList client type backed by RUNS_LIST_CLICKHOUSE_URL so this
high-traffic read path can target a read replica without moving ingest or
replication writes off CLICKHOUSE_URL. Falls back to CLICKHOUSE_URL when
unset, so it is a no-op unless configured.
Read-only clients (logs, query, admin, runsList, engine, realtime) now fall
back X_CLICKHOUSE_URL ?? CLICKHOUSE_READER_URL ?? CLICKHOUSE_URL, and the
events client uses the reader/writer split so trace/span/log reads hit the
replica while event + log inserts stay on the writer. Set CLICKHOUSE_READER_URL
once to move all reads off the primary. Writes (events, replication,
sessions_replication, standard) always stay on CLICKHOUSE_URL. No-op when
CLICKHOUSE_READER_URL is unset.
The run detail page loads a small prev/next navigation list via
NextRunListPresenter; point it at the runsList client too so all runs list
reads use the same dedicated client.
The events client both inserts events and reads traces/spans/logs through one
instance. Give it a dedicated reader URL so reads can move to a replica while
inserts stay on EVENTS_CLICKHOUSE_URL. Unlike the read-only clients, it does
not fall back to CLICKHOUSE_READER_URL: a write-capable client only moves reads
on an explicit opt-in.
@ericallam ericallam force-pushed the hotfix/runs-list-clickhouse-url branch from 00bee0f to 0bef4ee Compare July 15, 2026 12:41
@ericallam ericallam changed the base branch from clickhouse-reads-base to main July 15, 2026 12:41
@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@0bef4ee

trigger.dev

npm i https://pkg.pr.new/trigger.dev@0bef4ee

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@0bef4ee

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@0bef4ee

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@0bef4ee

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@0bef4ee

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@0bef4ee

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@0bef4ee

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@0bef4ee

commit: 0bef4ee

…fallback

The events read client (EVENTS_READER_CLICKHOUSE_URL) opts in explicitly and
does not fall back to CLICKHOUSE_READER_URL; the comment previously implied it did.
@ericallam ericallam marked this pull request as ready for review July 15, 2026 13:08

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

Open in Devin Review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 42d39d9b-0983-4d94-8e84-271dc47debb8

📥 Commits

Reviewing files that changed from the base of the PR and between c44792f and 6ff9f8a.

📒 Files selected for processing (1)
  • .server-changes/clickhouse-read-replica.md
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: code-quality / code-quality
  • GitHub Check: audit
  • GitHub Check: audit
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-14T14:54:39.095Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3545
File: .server-changes/agent-view-sessions.md:10-10
Timestamp: 2026-05-14T14:54:39.095Z
Learning: In the `trigger.dev` repository, do not flag inconsistent dot vs slash notation in route/path strings inside `.server-changes/*.md` files. These markdown files are consumed verbatim into the changelog, so the mixed notation (e.g., `resources.orgs.../runs.$runParam/...`) is intentional and should be preserved as-is.

Applied to files:

  • .server-changes/clickhouse-read-replica.md

Comment thread .server-changes/clickhouse-read-replica.md

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

Open in Devin Review

@ericallam ericallam merged commit 890dd66 into main Jul 15, 2026
35 checks passed
@ericallam ericallam deleted the hotfix/runs-list-clickhouse-url branch July 15, 2026 13:59
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants